package com.regvision.contacts.ui;

import com.regvision.contacts.R;
import com.regvision.contacts.domain.ContactDataModel;
import com.regvision.contacts.domain.EMailModel;
import com.regvision.contacts.domain.PhoneModel;
import com.regvision.contacts.utils.ContactsUtils;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;

public class NewContactActivity extends BaseActivity implements OnClickListener {

	private ContactDataModel mModel;

	private EditText etName;
	private EditText etPhone;
	private EditText etEMail;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_new_contact);

		findView();
		initData();
		initView();
	}

	private void findView() {
		findViewById(R.id.tv_new_contact_confirm).setOnClickListener(this);

		etName = (EditText) findViewById(R.id.et_new_contact_name);
		etPhone = (EditText) findViewById(R.id.et_new_contact_phone);
		etEMail = (EditText) findViewById(R.id.et_new_contact_mail);
	}

	private void initData() {
		// new 一个联系人实例，存储新联系人信息
		mModel = new ContactDataModel();
	}

	private void initView() {

	}

	private void initContact() {

		// 插入联系人名称
		mModel.name = etName.getText().toString().trim();

		// 插入联系人号码
		PhoneModel phone = new PhoneModel();
		phone.number = etPhone.getText().toString().trim();
		phone.type = 1;
		mModel.phones.add(phone);

		// 插入联系人邮箱
		EMailModel mail = new EMailModel();
		mail.address = etEMail.getText().toString().trim();
		mail.type = 1;
		mModel.emails.add(mail);
	}

	private void inserContact() {

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.tv_new_contact_confirm:
			ContactsUtils.testSave(NewContactActivity.this);
			break;

		default:
			break;
		}
	}
}
